package vis.core.common.valid.handler;

import vis.core.common.util.StringKit;
import vis.core.common.valid.IdCardNumber;
import vis.core.common.valid.ValidKit;
import vis.core.common.valid.base.ValidBaseHandler;
import vis.core.domain.sys.ServiceException;
import org.springframework.stereotype.Component;

/**
 * 枚举校验规则实现
 */
@Component
public class IdCardNumberHandler implements ValidBaseHandler<IdCardNumber, String> {

    // 第一个参数应该是注解
    @Override
    public void valid(IdCardNumber annotation, String paramName, String paramValue) {
        boolean check = ValidKit.idCardNumber.check(paramValue);
        if (!check)
            throw new ServiceException(StringKit.blankDefStr(annotation.msg(), "身份证号输入错误"));

    }

}
